1 Imports System.Data.OleDb
2 Public Class frmMain
3
4 Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
5 'TODO: This line of code loads data into the 'Schedule_dbDataSet.tblEvent' table. You can move, or remove it, as needed.
6 Me.TblEventTableAdapter.Fill(Me.Schedule_dbDataSet.tblEvent)
7 'TODO: This line of code loads data into the 'Schedule_dbDataSet.tblEvent' table. You can move, or remove it, as needed.
8
9 Timer1.Start()
10
11 Me.Width = 296
12
13 End Sub
14
15 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
16 If txtSubject.Text = "" Then
17 MsgBox("You must add a schedule subject!", vbExclamation, "Daily Schedule System")
18 ElseIf txtNote.Text = "No Note!" Or txtNote.Text = "" Then
19 Dim response As MsgBoxResult = MsgBox("You did not add a schedule note, Add now?", vbQuestion + vbYesNo, "Daily Schedule System")
20 If response = vbYes Then
21 txtNote.Text = ""
22 txtNote.Focus()
23 Else
24 txtNote.Text = "No Note!"
25 Save()
26 DataGridView1.Refresh()
27 Me.Update()
28 End If
29 Else
30 Check()
31 Save()
32 DataGridView1.Refresh()
33 Me.Update()
34 End If
35
36 End Sub
37
38 Public Sub Save()
39 Try
40 Dim Conn As New OleDbConnection("Provider=Microsoft.ACE.Oledb.12.0; Data Source=" & Application.StartupPath & "\schedule_db.accdb")
41 If Conn.State = ConnectionState.Open = True Then Conn.Close()
42 Conn.Open()
43
44 'Adding autonumbers to ID field in database
45 Dim AutoNumber As Long
46 For i As Long = 1 To 2
47 Randomize()
48 AutoNumber = Rnd(6) * 12 * 2
49 Next
50 'End autonumber generation
51
52 Dim SQL As New OleDbCommand
53 SQL.Connection = Conn
54 SQL.CommandText = "INSERT INTO tblEvent (ID, Subject, [Note], [Date], [Time]) VALUES ('" & AutoNumber & "', '" & txtSubject.Text & "', '" & txtNote.Text & "', '" & dtpDate.Text & "','" & dptTime.Text & "')"
55 SQL.ExecuteNonQuery()
56 MsgBox("Schedule succesfully saved!", vbInformation, "Daily Schedule System")
57
58 DataGridView1.Refresh()
59 Me.Update()
60
61
62 Catch ex As Exception
63 MsgBox("An error has occured - " & ex.Message, vbCritical, "Daily Schedule System")
64 End Try
65 End Sub
66
67 Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
68
69 lblTime.Text = Now
70 Try
71 Dim builder As New OleDbConnectionStringBuilder()
72 builder.DataSource = Application.StartupPath & "\schedule_db.accdb"
73 builder.Provider = "Microsoft.ACE.Oledb.12.0"
74
75 Using conn As New OleDbConnection(builder.ConnectionString)
76 conn.Open()
77 Dim rd As OleDbDataReader
78 Dim SQL As New OleDbCommand
79 SQL.Connection = conn
80 SQL.CommandText = "SELECT * FROM tblEvent WHERE (Date = '" & DateTime.Now.ToLongDateString & "')"
81 SQL.CommandType = CommandType.Text
82 rd = SQL.ExecuteReader
83 rd.Read()
84 If rd.HasRows Then
85 If rd.Item("Time") = DateTime.Now.ToLongTimeString Then
86 Dim AlertArray As New frmAlert()
87
88 AlertArray.lblSubject.Text = rd.Item("Subject")
89 AlertArray.lblNote.Text = rd.Item("Note")
90 AlertArray.lblDate.Text = rd.Item("Date")
91 AlertArray.lblE_Time.Text = rd.Item("Time")
92
93
94 Scheduler.Text = "Schedule time has reached"
95 AlertArray.Show()
96 AlertArray.Update()
97 'Timer2.Start()
98 'frmAlert.Update()
99 'frmAlert.Refresh()
100
101 End If
102 End If
103 End Using
104
105 Catch ex As Exception
106 MsgBox(ex.Message)
107 End Try
108
109 End Sub
110
111 Public Sub Check()
112 Try
113 Dim builder As New OleDbConnectionStringBuilder()
114 builder.DataSource = Application.StartupPath & "\schedule_db.accdb"
115 builder.Provider = "Microsoft.ACE.Oledb.12.0"
116
117 Using conn As New OleDbConnection(builder.ConnectionString)
118 conn.Open()
119 Dim rd As OleDbDataReader
120 Dim SQL As New OleDbCommand
121 SQL.Connection = conn
122 SQL.CommandText = "SELECT * FROM tblEvent WHERE (Subject = '" & txtSubject.Text & "')"
123 SQL.CommandType = CommandType.Text
124 rd = SQL.ExecuteReader
125 rd.Read()
126 If rd.HasRows = True Then
127 MsgBox("A schedule with this SUBJECT has already been added before... Use another subject!", vbExclamation, "Daily Schedule System")
128 Exit Sub
129 Else
130 End If
131 End Using
132
133 Catch ex As Exception
134 MsgBox(ex.Message)
135 End Try
136 End Sub
137
138 Private Sub btnRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRefresh.Click
139 Timer1.Start()
140 Timer1.Stop()
141 End Sub
142
143 Private Sub tmrRefresh_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrRefresh.Tick
144
145 DataGridView1.Refresh()
146 End Sub
147
148 Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpen.Click
149 If btnOpen.Text = "Show" Then
150 Me.Width = 884
151 Me.Height = 535
152 btnOpen.Text = "Close"
153 Else
154 Me.Width = 296
155 btnOpen.Text = "Show"
156 End If
157
158
159 End Sub
160
161 Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
162 Me.Hide()
163 Scheduler.Visible = True
164 Scheduler.Text = "Pro Scheduler is currently running!"
165 End Sub
166
167 Private Sub LinkLabel2_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel2.LinkClicked
168 Me.Hide()
169 Scheduler.Visible = True
170 Scheduler.Text = "Pro Scheduler is currently running!"
171 End Sub
172
173 Private Sub NotifyIcon1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Scheduler.DoubleClick
174 Me.Show()
175 End Sub
176
177 Private Sub OpenSchedulerToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenSchedulerToolStripMenuItem.Click
178 Me.Show()
179 End Sub
180
181 Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
182 System.Diagnostics.Process.Start("http://code-projects.org/")
183 End Sub
184
185 Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
186 Dim ques As String = "This will make the Scheduler Alert not to run at the proper time..." & vbCr
187 ques = ques + "Are you sure you want to exit?"
188 Dim ask As MsgBoxResult = MsgBox(ques, vbQuestion + vbYesNo, "Daily Schedule System - Confirm Exit")
189 If ask = vbYes Then
190 Application.Exit()
191 Else
192 Me.Hide()
193 Exit Sub
194 End If
195 End Sub
196
197 Private Sub ToolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem2.Click
198 System.Diagnostics.Process.Start("http://code-projects.org/")
199 End Sub
200
201 Private Sub ExitToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem1.Click
202 Dim ques As String = "This will make the Scheduler Alert not to run at the proper time..." & vbCr
203 ques = ques + "Are you sure you want to exit?"
204 Dim ask As MsgBoxResult = MsgBox(ques, vbQuestion + vbYesNo, "Daily Schedule System - Confirm Exit")
205 If ask = vbYes Then
206 Application.Exit()
207 Else
208 Me.Hide()
209 Exit Sub
210 End If
211 End Sub
212
213 Private Sub ToolStripMenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem3.Click
214 Me.Hide()
215 Scheduler.Visible = True
216 Scheduler.Text = "Pro Scheduler is currently running!"
217 End Sub
218
219
220 Private Sub LinkLabel4_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel4.LinkClicked
221 frmTegaton.ShowDialog()
222 End Sub
223
224 Private Sub LinkLabel3_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel3.LinkClicked
225 frmTegaton.ShowDialog()
226 End Sub
227
228 Private Sub PictureBox1_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseHover
229 PictureBox1.Image = My.Resources.codepro4thmakingPNGWHITE
230 End Sub
231
232 Private Sub PictureBox1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseLeave
233 PictureBox1.Image = My.Resources.logo
234 End Sub
235
236 Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click
237
238 End Sub
239 End Class